perm filename RIGHT[E,ALS] blob sn#235237 filedate 1976-09-08 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	TJU1
C00008 ENDMK
CāŠ—;
;TJU1

;  Special treatment if new par for TJ case
TJU1:	SETZB Q,J
	SKIPG TABOLD(Q)		;Are tab fields expected?
	JRST JU2		;No
TJU1A:	MOVE K,TPMAR
	MOVEM K,TABEND#
	TLNE F,TF1		;Which pass?
	JRST TJU1B
	TRZ F,REL		;Must be redetermined during first pass
	SKIPGE TABFLG
	TRO F,REL		;All lines are table lines for TABLE command
	SETOM TF2FLG#		;Signalling first pass on a table line
TJU1B:	SETOM ODDEVN		;To keep odd-even check on tabs
	MOVEI TT,77777
	SKIPGE TABFLG		;Is neg for TFJ commands
	MOVE TT,TPMARO
	MOVEM TT,TABENO#
	JUMPE TT,TJU3B
TJU2:	MOVEI DSP,TJ1DSP
	MOVSI H,JALL
	
;  Space eating loop (for both passes)
TJU3:	ILDB C,A		;Eat spaces, odd-even check tabs, to next field
TJU3A:	TLNE H,JCTAB(C)
	XCT @JCTAB(C)
	CAMGE J,TABENO
	JRST TJU3

	CAML J,TABENO		;Did we arrive at an entry too soon?
	JRST TJU3B		;No
	ADD A,[70000,,0]	;Yes, so back up
	CAIG A,0
	SUB A,[430000,,1]
	JRST TJU3C

TJU3B:	SKIPG ODDEVN		;Is there an unmatched tab?
	JRST TJU3C		;No
	MOVE T,A
	ILDB C,T		;Sneak look at next char
	CAIE C,11
	JRST TJU3C		;Must be char for next field
	ILDB C,A		;Eat it
	MOVNS ODDEVN		;and account for it
TJU3C:	TLNE F,TF1
	JRST TJU6		;Second pass
	SKIPLE TT,TABOLD(Q)
	JRST TJU4D		;Can continue
;  Out of tab fields but is there any text on this line?
	MOVE T,A
TJU4A:	ILDB C,T
	CAIE C,40
	CAIN C,11
	JRST TJU4A		;Eat spaces and tabs
	CAIE C,15
	CAIN C,12
	JRST TJU4C		;End of this input line
TJU4B:	CAILE K,(G)
	AOBJN G,TJU4B
	JRST JU2		;Go read the text

TJU4C:	PUSHJ P,PARGET
	TRNN F,REL
	JRST TJU4B		;There is text on the next line
	HRRZM G,JWCOL		;Character count for second pass
	SETZ JSINC		;To suppress any attempt to justify if no text
	JRST JU3B		;Go to second pass


TJU4D:	JUMPE Q,TJU4F		;Initial indent is handled differently
	CAILE K,(G)
	AOBJN G,.-1		;Allow for the normal field length
TJU4F:	SKIPGE TABFLG
	HRRZM TT,TABENO		;New input field end
	HRRZ K,TABTAB(Q)	;Establish the new output field termination
	SUB K,TPMAR		;Remember that G right is to measure from TPMAR
	JUMPG Q,TJU4E
	TLNN F,TF1
	HLLZS G			;First time fix so that G measures from TPMAR
TJU4E:	AOS Q
	MOVEI DSP,TJ2DSP
	MOVSI H,JUSF

;  First pass character count
TJU5:	ILDB C,A
	TDNE H,JCTAB(C)
	XCT @JCTAB(C)
	AOJA J,TJU5A		;Count input character and JUMP
	AOBJN G,TJU2		;Count second space here
	MOVEI DSP,J1DSP
	MOVSI H,JALL
	JRST JU2		;Let normal JUST or JFILL routine handle it

;  Normal character portion of loop
TJU5A:	AOBJN G,TJU5		;Account for normal character
	MOVEI DSP,J2DSP
	MOVSI H,JUSF
	JRST JU3A1

TJU6:	SKIPLE TT,TABOLD(Q)
	JRST TJU8
;  There may be text to follow
	MOVE T,A
TJU6A:	ILDB C,T
	CAIE C,40
	CAIN C,11
	JRST TJU6A		;Eat spaces and tabs
	CAIE C,15
	CAIN C,12
	JRST TJU7C		;End of this input line
TJU7:	MOVEI C,40		;Pad out with spaces to end of this field
TJU7A:	CAIG K,(G)
	JRST TJU7B
LEG	IDPB C,D
	AOBJN G,TJU7A

TJU7B:	MOVEI DSP,J1DSP		;Go read text
	MOVSI H,JALL
	JRST JU4

TJU7C:	TRNN F,REL		;Are we to go to the next line?
	JRST TJU7		;Yes
	JRST JU4A		;No, we are through

TJU8:	JUMPE Q,TJU8B		;First indent handled by J2PASS
	MOVEI C,40		;Pad out with spaces to next field start
TJU8A:	CAIG K,(G)
	JRST TJU8B
LEG	IDPB C,D
	AOBJN G,TJU8A
TJU8B:	SKIPGE TABFLG
	HRRZM TT,TABENO		;New input field end
	HRRZ K,TABTAB(Q)
	SUB K,TPMAR		;Remember that G is measured from TPMAR
	AOS Q
	MOVEI DSP,TJ2DSP
	MOVSI H,JUSF

;  Second pass character transfer
TJU9:	ILDB C,A
	TDNE H,JCTAB(C)
	XCT @JCTAB(C)
LEG	IDPB C,D
	AOJA J,TJU9A		;Count input character and JUMP
	AOBJN G,TJU2		;Count second space here
	JRST JU4A


TJU9A:	AOBJN G,TJU9		;Count transfered character
	JRST JU4A